package com.xmu.makerspace.service;

import com.xmu.makerspace.dao.FormalTeamRepository;
import com.xmu.makerspace.dao.MidAuditRepository;
import com.xmu.makerspace.dao.MiddleTermResultRepository;
import com.xmu.makerspace.domain.FormalTeam;
import com.xmu.makerspace.domain.MiddleTermResult;
import com.xmu.makerspace.domain.MiddleTermSubmit;
import com.xmu.makerspace.model.seat.MaterialDTO;
import org.springframework.stereotype.Service;

@Service
public class MidAuditService {
    private MidAuditRepository repository;
    private FormalTeamRepository formalTeamRepository;//团队状态接口
    private MiddleTermResultRepository middleTermResultRepository;//中期提交结果的接口
    private MiddleTermResult middleTermResult;//中期提交结果
    public FormalTeam formalTeam;//团队状态
    public MidAuditService(MidAuditRepository repository,FormalTeamRepository formalTeamRepository,MiddleTermResultRepository middleTermResultRepository)
    {
        this.repository=repository;
        this.formalTeamRepository=formalTeamRepository;
        this.middleTermResultRepository=middleTermResultRepository;
    }//初始化分配成员空间
    public void addMiddle_term_submit(MaterialDTO dto)
    {
        MiddleTermSubmit middle_term_submit=new MiddleTermSubmit();
        middle_term_submit.setPlan(dto.getPlan());
        middle_term_submit.setProjectAchievement(dto.getProjectAchievement());
        middle_term_submit.setProjectProgress(dto.getProjectProgress());
        middle_term_submit.setSubmitId(dto.getSubmitId());
        middle_term_submit.setTeamId(dto.getTeamId());
        repository.save(middle_term_submit);
    }
    public int findTeamById(int teamId)//获取团队进程数据
    {
        formalTeam=this.formalTeamRepository.findAllByTeamId(teamId);
        return formalTeam.getAuditStep();
    }

    public MiddleTermResult getMiddleTermResult(int teamId)//获取团队中期评价
    {
        middleTermResult=this.middleTermResultRepository.findAllByTeamId(teamId);
        return middleTermResult;
    }
}
